package com.ydlclass.channelHandler;

import com.ydlclass.channelHandler.handler.MySimpleChannelInboundHandler;
import com.ydlclass.channelHandler.handler.YrpcRequestEncoder;
import com.ydlclass.channelHandler.handler.YrpcResponseDecoder;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;

/**
 * @author Knife
 */
public class ConsumerChannelInitializer extends ChannelInitializer<NioSocketChannel> {
    @Override
    protected void initChannel(NioSocketChannel ch) throws Exception {

        ch.pipeline()
                // netty自带的日志处理器
                .addLast(new LoggingHandler(LogLevel.DEBUG))
                // 消息编码器
                .addLast(new YrpcRequestEncoder())
                // 入栈的解码器
                .addLast(new YrpcResponseDecoder())
                .addLast(new MySimpleChannelInboundHandler());

    }
}
